'use strict';

const QS = require('querystring'),  Utility = require('../libs/utility');



const DataModel = Utility.abstractClass(function(context, data) {

        this.setPrivate('name', this.constructor.name);

        this.setPrivate('data', { });

        Object.assign(this,  data || { });

    },  ['search', 'append', 'update', 'remove']);

DataModel.Hash2SQL = function (data, assign, separator) {

    return  QS.stringify(data, separator, assign, {
        encodeURIComponent:    JSON.stringify
    });
};

DataModel.prototype.valueOf = function () {

    return  Object.assign({ },  this.__data__);
};


module.exports = DataModel;
